<script setup lang="ts">

let response = ref()
import {ref} from "vue";
import {taskImage} from "../store/taskStore.ts";
import html2canvas from "html2canvas";
import {getCurrentIP} from "../network/mapApi.ts";
// getCurrentIP().then(res=>{
//   console.log(res.data)
//   response.value = res.data
//
// })


//初始化地图对象
map = new T.Map("mapDiv");
//设置显示地图的中心点和级别
map.centerAndZoom(new T.LngLat(116.40969, 38.89945), zoom);
var lo = new T.Geolocation();
fn = function (e) {
  if (this.getStatus() == 0){
    map.centerAndZoom(e.lnglat, 15)
    alert("获取定位坐标："+e.lnglat.lat + "," + e.lnglat.lng)
    var marker = new T.Marker(e.lnglat);
    map.addOverLay(marker);
  }
  if(this.getStatus() == 1){
    map.centerAndZoom(e.lnglat, e.level)
    alert("获取定位坐标："+e.lnglat.lat + "," + e.lnglat.lng)
    var marker = new T.Marker(e.lnglat);
    map.addOverLay(marker);
  }
}
lo.getCurrentPosition(fn);






</script>

<template>
<!--  <div>{{response}}</div>-->

  <div id="mapDiv"></div>
  <p>本示例演示如用H5定位所在城市</p>
</template>

<style scoped>

</style>